<?php
	session_start();
	require_once("../../db/dbclass.php");
	// require_once("../utils/config.php");
	$myDb=&DbController::getInstance();
	$username=$_POST["username"];
	$password=$_POST["userpassword"];
	$_SESSION['name']=$username;
	// setcookie("name", $username, time()+3600);
	$param="select user_power from yj_user_info where user_name ='".$username."' and user_password ='".$password."'";
	$result = $myDb->exec_query($param);
	if($result==TRUE){
		while($row = mysqli_fetch_array($result,MYSQL_ASSOC)){
			switch ($row['user_power']) {
				// 管理员页面
				case '0':
					echo "<script>";
					echo "location.href=\"../HTML/admin/index.html?name=$username\";";
					echo "</script>";
					return ;
				// 开发者页面
				case '2':
					echo "<script>";
					echo "location.href=\"../HTML/admin/yourplugin.html?name=$username\";";
					echo "</script>";
					return;
				default:
					echo "<script>";
					echo "location.href=\"../HTML/login.html?result=1\";";
					echo "</script>";
					return;
			}
		}
	}
	echo "<script>";
	echo "location.href=\"../HTML/login.html?result=2\";";
	echo "</script>";
	return;
?>